package com.xiaode.common;

import com.jfinal.kit.Ret;
import com.jfinal.render.Render;
import com.jfinal.render.RenderManager;

public class MyErrorRender extends Render {



	protected static final String contentType = "text/html; charset=" + getEncoding();
	
	protected int errorCode;

	public MyErrorRender(int errorCode) {
		this.errorCode = errorCode;
	}

	@Override
	public void render() {
		response.setStatus(getErrorCode());	// HttpServletResponse.SC_XXX_XXX
		response.setContentType(contentType);
		RenderManager.me().getRenderFactory().getJsonRender(Ret.fail().set("msg", getErrorCode())).setContext(request, response).render();
		return;
	}
	
	public int getErrorCode() {
		return errorCode;
	}
}
